package br.com.ufc.quixada.util;


import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author FuscaoGames
 */
public class HibernateUtil {
    private static SessionFactory sessionFactory;

    private static SessionFactory getSessionFactory() throws MappingException
    {
        if(sessionFactory == null)
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        return sessionFactory;
    }

    public static Session getSession()
    {
        return getSessionFactory().openSession();
    }
}
